//
//  ST_UpdateInfoHeader.swift
//  BTVideo
//
//  Created by DouLei on 2019/8/3.
//  Copyright © 2019 DouLei. All rights reserved.
//

import UIKit
import SwifterSwift


class ST_UpdateInfoHeader: UIView {

    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.addSubview(header_image_view)
        self.addSubview(head_mask_view)
        self.addSubview(modify_image_view)
        header_image_view.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalToSuperview().offset(15)
            make.width.height.equalTo(header_image_height)
        }
        head_mask_view.snp.makeConstraints { (make) in
            make.center.equalTo(header_image_view)
            make.width.height.equalTo(header_image_view)
        }
        modify_image_view.snp.makeConstraints { (make) in
            make.center.equalTo(header_image_view)
        }
        
        
        self.addSubview(describe_label)
        describe_label.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(header_image_view.snp.bottom).offset(10)
        }
        
//        let line = UIView()
//        line.backgroundColor = Color.init(hex: 0xF2F4F7)
//        self.addSubview(line)
//        line.snp.makeConstraints { (make) in
//            make.height.equalTo(5)
//            make.left.right.bottom.equalToSuperview()
//        }
        
        addSubview(modify_btn)
        modify_btn.snp.makeConstraints { (make) in
            make.left.right.top.equalTo(header_image_view)
            make.bottom.equalTo(describe_label)
        }
        
    }
    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    let header_image_height = 100.cgFloat
    
    lazy var header_image_view:UIImageView = {
        let control = UIImageView()
        control.contentMode = UIView.ContentMode.scaleAspectFill
        control.cornerRadius = header_image_height/2.0
        control.borderWidth = 4
        control.borderColor = UIColor.white
        return control
    }()
    
    lazy var head_mask_view:UIView = {
        
        let control = UIView()
        
        control.backgroundColor = UIColor.init(white: 0, alpha: 0.4)
        
        control.cornerRadius = header_image_height/2.0
        
        return control
    }()
    
    
    lazy var modify_image_view:UIImageView = {
        let control = UIImageView()
        control.image = ST_ImageUtils.imageName("UserCenter_mycenter_icon_修改头像")
        return control
    }()
    

    
    
    lazy var describe_label:UILabel = {
       let control = UILabel()
        let attrString = NSMutableAttributedString(string: "点击更换头像")
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 12, weight: UIFont.Weight.regular),.foregroundColor: UIColor(red: 0.6, green: 0.6, blue: 0.6, alpha: 1)]
        attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        control.attributedText = attrString
        return control
    }()
    
    
    lazy var modify_btn:UIButton = {
        
        let control = UIButton.init(type: UIButton.ButtonType.custom)
       
        control.addTarget(self, action: #selector(push_modify_handle), for: UIControl.Event.touchUpInside)
        return control
    }()
    
    
    
    var push_modify_closure:(()->())?
    @objc  func push_modify_handle(){
        push_modify_closure?()
    }
}
